package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.CustomerFavorite;
import com.pgybook.db.entity.domain.CustomerFavoriteEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface CustomerFavoriteMapper {
    int countByExample(CustomerFavoriteEx example);

    int deleteByExample(CustomerFavoriteEx example);

    @Delete({
            "delete from customerfavorite",
            "where CUSTFAVORITEID = #{custfavoriteid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer custfavoriteid);

    @Insert({
            "insert into customerfavorite (BOOKID, CUSTID, ",
            "CRTTIME)",
            "values (#{bookid,jdbcType=BIGINT}, #{custid,jdbcType=BIGINT}, ",
            "#{crttime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "custfavoriteid", before = false, resultType = Integer.class)
    int insert(CustomerFavorite record);

    int insertSelective(CustomerFavorite record);

    List<CustomerFavorite> selectByExample(CustomerFavoriteEx example);

    @Select({
            "select",
            "CUSTFAVORITEID, BOOKID, CUSTID, CRTTIME",
            "from customerfavorite",
            "where CUSTFAVORITEID = #{custfavoriteid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    CustomerFavorite selectByPrimaryKey(Integer custfavoriteid);

    int updateByExampleSelective(@Param("record") CustomerFavorite record, @Param("example") CustomerFavoriteEx example);

    int updateByExample(@Param("record") CustomerFavorite record, @Param("example") CustomerFavoriteEx example);

    int updateByPrimaryKeySelective(CustomerFavorite record);

    @Update({
            "update customerfavorite",
            "set BOOKID = #{bookid,jdbcType=BIGINT},",
            "CUSTID = #{custid,jdbcType=BIGINT},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP}",
            "where CUSTFAVORITEID = #{custfavoriteid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CustomerFavorite record);
}
